package com.bjpowernode.controller;

import com.bjpowernode.entity.TActivity;
import com.bjpowernode.query.ActivityQuery;
import com.bjpowernode.result.Result;
import com.bjpowernode.service.ActivityService;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 活动controller
 */
@RestController
@RequiredArgsConstructor
public class ActivityController {

    public final ActivityService activityService;

    @GetMapping("/api/activity")
    public Result getActivity(Integer current, ActivityQuery activityQuery) {
        PageInfo<TActivity> pageInfo = activityService.getActivityByPage(current,activityQuery);
        return Result.OK(pageInfo);
    }

    /**
     * 查询活动明细
     */
    @GetMapping("/api/activity/{id}")
    public Result getActivityById(@PathVariable Integer id) {
        TActivity tActivity = activityService.selectById(id);
        return Result.OK(tActivity);
    }

}
